package com.infnoon.parking.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.infnoon.parking.common.ErrorCode;
import com.infnoon.parking.exception.BusinessException;
import com.infnoon.parking.model.entity.Parkingbill;
import com.infnoon.parking.service.ParkingbillService;
import com.infnoon.parking.mapper.ParkingbillMapper;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author 31124
* @description 针对表【parkingbill】的数据库操作Service实现
* @createDate 2024-12-16 14:54:54
*/
@Service
public class ParkingbillServiceImpl extends ServiceImpl<ParkingbillMapper, Parkingbill>
    implements ParkingbillService {
    @Override
    public void saveParkingbill(int ParkingRecordID, Date date, Float ParkingFee) {
        Parkingbill parkingbill = Parkingbill.builder()
                .parkingRecordID(ParkingRecordID)
                .date(date)
                .parkingFee(ParkingFee)
                .build();

        boolean saveResult = this.save(parkingbill);
        if (!saveResult) {
            throw new BusinessException(ErrorCode.SYSTEM_ERROR, "停车失败，数据库错误");
        }
    }
}




